<?php
header("content-type:text/html;charset=utf-8");
include '../model/config.inc.php';
include '../model/functions.inc.php';
include 'Page.class.php';
include '../model/Model.class.php';

$user=M('user');
$count=$user->field('count(*) cnt')->select();

// 分页类
$page=new Page($count[0]['cnt'],2);

?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>分页</title>
</head>
<body>
	<center>
		<h3>分页</h3>
		<table border="1" cellspacing="0" width="600px">
			<tr>
				<th>ID</th>
				<th>用户名</th>
				<th>密码</th>
				<th>注册时间</th>
			</tr>
			<?php								
				$rows=$user->where('id>1')->order('id')->limit($page->limit)->select();
				// 遍历数组
				foreach($rows as $row){
					echo "<tr>";
					echo "<td>{$row['id']}</td>";
					echo "<td>{$row['username']}</td>";
					echo "<td>{$row['password']}</td>";
					echo "<td>".date('Y-m-d H:i:s',$row['time'])."</td>";
					echo "</tr>";
				}
			?>
		</table>
		<?php
			$page->show();
		?>
	</center>
</body>
</html>